#!/bin/bash
#
# Copyright (c) 2013-2021 Igor Pecovnik, igor.pecovnik@gma**.com
#
# This file is licensed under the terms of the GNU General Public
# License version 2. This program is licensed "as is" without any
# warranty of any kind, whether express or implied.
#
# This file is a part of the Armbian build script
# https://github.com/armbian/build/

NAME_KERNEL="Image"
NAME_INITRD="uInitrd"
MAIN_CMDLINE="rootflags=data=writeback rw no_console_suspend consoleblank=0 fsck.fix=yes fsck.repair=yes net.ifnames=0 bootsplash.bootfile=bootsplash.armbian"
[[ -z $INITRD_ARCH ]] && INITRD_ARCH=arm64
QEMU_BINARY="qemu-aarch64-static"
ARCHITECTURE=arm64
ARCH=arm64
KERNEL_IMAGE_TYPE=Image
CAN_BUILD_STRETCH=yes

if [ "$(uname -m)" = "aarch64" ]; then
	[[ $ATF_COMPILE != "no" && -z $ATF_COMPILER ]] && ATF_COMPILER="aarch64-linux-gnu-"
	[[ -z $UBOOT_COMPILER ]] && UBOOT_COMPILER="aarch64-linux-gnu-"
	[[ -z $KERNEL_COMPILER ]] && KERNEL_COMPILER="aarch64-linux-gnu-"
	[[ -z $KERNEL_USE_GCC ]]        && KERNEL_USE_GCC='> 8.0'
else
	[[ $ATF_COMPILE != "no" && -z $ATF_COMPILER ]] && ATF_COMPILER="aarch64-none-linux-gnu-"
	[[ -z $UBOOT_COMPILER ]] && UBOOT_COMPILER="aarch64-none-linux-gnu-"
	# > 9.2 https://armbian.atlassian.net/browse/AR-557
	# [[ -z $KERNEL_COMPILER ]]     && KERNEL_COMPILER="aarch64-none-linux-gnu-"
	[[ -z $KERNEL_COMPILER ]]       && KERNEL_COMPILER="aarch64-linux-gnu-"
	[[ -z $KERNEL_USE_GCC ]]        && KERNEL_USE_GCC='< 9.2'
fi

[[ $ATF_COMPILE != "no" && -z $ATFSOURCE ]] && ATFSOURCE='https://github.com/ARM-software/arm-trusted-firmware'
[[ $ATF_COMPILE != "no" && -z $ATFDIR ]] && ATFDIR='arm-trusted-firmware-sunxi-mainline'
[[ $ATF_COMPILE != "no" && -z $ATFBRANCH ]] && ATFBRANCH='branch:master'
[[ $ATF_COMPILE != "no" && -z $ATF_USE_GCC ]] && ATF_USE_GCC='> 8.0'

[[ -z $UBOOT_USE_GCC ]]	&& UBOOT_USE_GCC='> 8.0'
[[ -z $BOOTSOURCE ]]		&& BOOTSOURCE=$MAINLINE_UBOOT_SOURCE
[[ -z $BOOTDIR ]]		&& BOOTDIR=$MAINLINE_UBOOT_DIR
[[ -z $BOOTBRANCH ]]		&& BOOTBRANCH='tag:v2020.04'

[[ -z $KERNELDIR ]]		&& KERNELDIR=$MAINLINE_KERNEL_DIR
[[ -z $KERNELSOURCE ]]		&& KERNELSOURCE=$MAINLINE_KERNEL_SOURCE
[[ -z $KERNELBRANCH ]]		&& KERNELBRANCH='branch:linux-5.4.y'
